#include "Fifo.hpp"
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string>
#include <fcntl.h>
#include <iostream>

int main()
{
    int fd = open(Path, O_WRONLY);
    cout << "write_open" << endl;
    if (fd < 0)
    {
        cerr << "open error:" << errno << endl;
        return 1;
    }
    // 向命名管道中写内容
    string str;
    int cnt = 1;
    while (cnt <= 3)
    {
        cout << "Please input your message: ";
        getline(cin, str);
        if (str == "quit")
            break;

        int n = write(fd, str.c_str(), str.size());
        if (n < 0)
        {
            cerr << "write error:" << errno << endl;
        }
        cnt++;
        sleep(1);
    }
    close(fd);
    return 0;
}